home *** CD-ROM | disk | FTP | other *** search
- { Turbo Pascal removable window system
- Copywrite 1984 Michael A. Covington }
-
- { Requirements: IBM PC or close compatible.
- Screen must be in text mode on page 1,
- either mono or color card.
-
- Call INITWIN berfore calling MKWIN or RMWIN
- }
-
- const maxwin = 5; { maximum number of windows open at once }
-
- type imagetype = array [1..4096] of char;
- windimtype = record
- x1,y1,x2,y2: integer
- end;
-
- var win: { global variable package }
- record
- dim: windimtype; { current window dimensions }
- depth: integer;
- stack: array [1..maxwin] of
- record
- image: imagetype; { Saved screen attributes }
- dim: windimtype; { Saved window dimensions }
- x,y: integer; { Saved cursor position }
- end
- end;
-
- crtmode: byte absolute $0040:$0049;
- crtwidth: byte absolute $0040:$004A;
- monobuffer: imagetype absolute $B000:$0000;
- colorbuffer: imagetype absolute $B800:$0000;
-
- {================}
- procedure initwin;
- {================}
-
- { Records initial window dimensions }
-
- begin
- with win.dim do
- begin x1:=1; y1:=1; x2 := crtwidth; y2:=25 end;
- win.depth := 0
- end;
-
- {=====================================}
- procedure boxwin(x1,y1,x2,y2: integer);
- {=====================================}
-
- { Draws a box, fills it with blanks, and makes it the current
- winddow. Dimensions given are for the box; actual window
- is one unit smaller in each direction.
- This routine can be used seperately from the rest of the
- removable window package.
- }
- var x,y: integer;
-
- begin
- window(1,1,80,25);
-
- {top}
- gotoxy(x1,y1);
- write(#213);
- for x:=x1+1 to x2-1 do write(#205);
- write(#184);
-
- {sides}
- for y := y1+1 to y2-1 do begin
- gotoxy(x1,y);
- write(#179,' ':x2-x1-1,#179);
- end;
-
- {bottom}
- gotoxy(x1,y2);
- write(#212);
- for x := x1+1 to x2-1 do write(#205);
- write(#190);
-
- {make it the current window}
- window(x1+1,y1+1,x2-1,y2-1);
- gotoxy(1,1)
- end;
-
- {===================================}
- procedure mkwin(x1,y1,x2,y2:integer);
- {===================================}
-
- { Create a removable window }
-
- begin
- { increment stack pointer }
- with win do depth := depth + 1;
- if win.depth > maxwin then begin
- writeln(^G,' Windows nested too deep ');
- halt
- end;
-
- { save contents of the screen }
- if crtmode = 7 then
- win.stack[win.depth].image := monobuffer
- else
- win.stack[win.depth].image := colorbuffer;
-
- win.stack[win.depth].dim := win.dim;
- win.stack[win.depth].x := wherex;
- win.stack[win.depth].y := wherey;
-
- { create the window }
- boxwin(x1,y1,x2,y2);
- win.dim.x1 := x1+1;
- win.dim.y1 := y1+1;
- win.dim.x2 := x2-1;
- win.dim.y2 := y2-1;
- end;
-
- {==============}
- procedure rmwin;
- {==============}
-
- { Remove the most recently created removable window
- Restore screen contents, winodw dimensions, and
- position of coursor. }
-
- begin
- if crtmode = 7 then
- monobuffer := win.stack[win.depth].image
- else
- colorbuffer := win.stack[win.depth].image;
-
- with win do begin
- dim := stack[depth].dim;
- window(dim.x1,dim.y1,dim.x2,dim.y2);
- gotoxy(stack[depth].x,stack[depth].y);
- depth := depth - 1
- end
- end;